import java.util.Scanner;

public class Demo2_6 {
    //写一个递归方法，输入一个非负整数，返回组成它的数字之和
    public static int sumNum(int k) {
        if (k < 10) {
            return k;
        }
        int ret = sumNum(k / 10) + (k % 10);
        return ret;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入一个非负整数：");
        int n = scan.nextInt();
        System.out.println(sumNum(n));
    }
}
